<?php

App::uses('Crud', 'Model');

class LogAddressUser extends Crud {
    const STATUS_ENABLED = 1;
    const STATUS_DISABLED = 0;

    public function getLastAddress($userId) {
        $filters = array(
            'fields' => array(
                'street',
                'number',
                'colony',
                'between_streets'
            ),
            'conditions' => array(
                'user_id' => $userId,
                'status' => self::STATUS_ENABLED
            ),
            'order' => array(
                'creation_date DESC'
            )
        );

        $result = $this->find('first', $filters);
        return $result;
    }
}